package edu.lnu.project.timeeditapp.activites;

import android.app.ActionBar;
import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

import com.lnu.project.timeeditapp.R;

import edu.lnu.project.timeeditapp.adapter.VisibilityColorAdapter;
import edu.lnu.project.timeeditapp.helper.MyHelper;

public class VisibilityColorScreen extends ListActivity {


	Context mContext;
	VisibilityColorAdapter adapter;
	int[] courseIdList;
	Resources res;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.visibility_color_screen);
		
		mContext = this;
		MyHelper.initializeSharedPreferences(this);

		adapter = new VisibilityColorAdapter(this, MyHelper.visibilityArray, R.layout.visibility_color_item, 
				new String[]{MyHelper.COURSENAME, MyHelper.VISIBILITY, MyHelper.COLOR},
				new int[]{R.id.courseName, R.id.visibilityButton, R.id.colorButton});

		setListAdapter(adapter);
		
		Button okButton = (Button) findViewById(R.id.save_visibility_color);
		okButton.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent result = new Intent(mContext, ListViewActivity.class);
				setResult(Activity.RESULT_OK, result);
				finish();
			}
		});
		
		//Set up the action bar
		ActionBar actionBar = getActionBar();
	    actionBar.setDisplayHomeAsUpEnabled(true);
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		finish();
		return super.onOptionsItemSelected(item);
	}

	

}
